package com.kaizige.realtor.Dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.Map;

@Repository
public class managerDao {
	@Autowired
	JdbcTemplate jdbcTemplate;
	
	// 按名字查找管理员信息
	public Map<String, Object> queryByName(String userName){
		Map<String, Object> map;
		try{
			String sql = "select * from manager where name=?";
			map = jdbcTemplate.queryForMap(sql, userName);
		}catch(EmptyResultDataAccessException e){
			return null;
		}
		return map;
	}
	
	// 加钱
	public void getRent(){
		String sql = "update manager set balance = balance + 100 where name=?";
		jdbcTemplate.update(sql,"admin1");
	}
	public void getSeeHou(){
		String sql = "update manager set balance = balance + 50 where name=?";
		jdbcTemplate.update(sql,"admin1");
	}
}
